package com.hc.wdj.auth.server.template;

import com.hc.wdj.auth.server.data.model.ClientModel;
import com.hc.wdj.auth.server.error.OAuthError;
import com.hc.wdj.auth.server.manager.OAuthManager;
import com.hc.wdj.core.exception.HcException;

/**
 * 模块 代码实现
 * @author ryanwdj
 * @since 2024/11/18
 */
public class OAuthTemplate {

    public ClientModel getClientModel(String clientId){
        return OAuthManager.getDataLoader().getClientModel(clientId);
    }

    public ClientModel checkClientModel(String clientId){
        ClientModel clientModel = getClientModel(clientId);
        if(clientModel == null){
            throw new HcException(OAuthError.INVALID_CLIENT_ID, clientId);
        }
        return clientModel;
    }
}
